package org.qdao;

import java.lang.reflect.InvocationTargetException;
import java.sql.Connection;
import java.sql.SQLException;

public interface IDBEngine {
    
    
    /**
     * 是否可以连接
     * @return
     */
    boolean checkConnection();
    
    
    DBConfig getConfig();
	/**
	 * 初始化配置信息
	 * 
	 * @author tan
	 * @param config
	 * @return
	 * @throws InstantiationException
	 * @throws IllegalAccessException
	 * @throws ClassNotFoundException
	 * @throws SQLException
	 *             2010/03/03 11:49:54
	 */
	public boolean initialize(DBConfig config) throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException;

	/**
	 * 关闭引擎
	 * 
	 * @author tan 2010/03/03 11:49:43
	 */
	public void dispose();

	/**
	 * 获取 java.sql.Connection 对象
	 * 
	 * @author tan
	 * @return
	 * @throws SQLException
	 * @throws InstantiationException
	 * @throws IllegalAccessException
	 * @throws ClassNotFoundException
	 *             2010/03/03 11:49:28
	 */
	public Connection getConnection() throws SQLException, InstantiationException, IllegalAccessException, ClassNotFoundException;

	/**
	 * 
	 * *
	 * 
	 * <pre>
	 * engine.getEntityDao(Cat.class);
	 * 
	 * 默认是记录日志的
	 * </pre>
	 * 
	 * @author tan
	 * @param entity
	 * @return
	 * @throws IllegalArgumentException
	 * @throws SecurityException
	 * @throws InstantiationException
	 * @throws IllegalAccessException
	 * @throws InvocationTargetException
	 * @throws NoSuchMethodException
	 *             2010/03/03 11:49:08
	 */
	public IEntityDao<?> getEntityDao(Class<?> entity) throws IllegalArgumentException, SecurityException, InstantiationException, IllegalAccessException,
			InvocationTargetException, NoSuchMethodException;

	/**
	 * 
	 * <pre>
	 * engine.getEntityDao(Cat.class, false);
	 * </pre>
	 * 
	 * @author tan
	 * @param entity
	 *            实体类的class
	 * @param isLogger
	 *            是否记录日志
	 * @return
	 * @throws IllegalArgumentException
	 * @throws SecurityException
	 * @throws InstantiationException
	 * @throws IllegalAccessException
	 * @throws InvocationTargetException
	 * @throws NoSuchMethodException
	 *             2010/03/03 11:47:59
	 */
	public IEntityDao<?> getEntityDao(Class<?> entity, boolean isLogger) throws IllegalArgumentException, SecurityException, InstantiationException, IllegalAccessException,
			InvocationTargetException, NoSuchMethodException;

	public boolean support(DBConfig config);

	public TableDescriptor getTableDescriptor(Class<?> table);
	
	void log (final Object msg);
}
